const {
  $util,
} = getApp();
Page({
  data: {
    showMore: false,
    showMore2: false,
    showMore3: false,
    imgUrl: $util.getImgUrl(),
  },
  getMore() {
    this.setData({
      showMore: !this.data.showMore,
    });
  },
  getMore2() {
    this.setData({
      showMore2: !this.data.showMore2,
    });
  },
  getMore3() {
    this.setData({
      showMore3: !this.data.showMore3,
    });
  },
  onShow() {
    let wxData = wx.getStorageSync('qyUserInfo') || {};
    this.setData(wxData);
    this.setData({
      isSaaS: wx.getStorageSync('isSaaS'),
    });
  },
  onLoad(opts) {
    this.setData(opts, () => {
      this.loadDetail(0);
      this.loadDetail(1);
    });
  },
  /**
   * 获取与会人员详情
   *
   */
  loadDetail(ptype) {
    $util.request({
      url: 'entry/wxapp/partylife.sessions.getmeetpeople',
      data: {
        id: this.data.id,
        ptype,
      },
      success: (res) => {
        if (ptype === 0) {
          this.setData({
            presenceList: res.data,
            isPLoad: true,
          });
        }
        if (ptype === 1) {
          let signTip1 = 0; // 缺席人个数
          let signTip2 = 0; // 请假人个数
          let arr = res.data;
          for (let i = 0; i < arr.length; i++) {
              if (Number(arr[i].sign) === 0) {
                signTip1++;
            } else {
              if (Number(arr[i].sign) === 2) {
                signTip2++;
              }
            }
          }
          this.setData({
            absenceList: res.data,
            isALoad: true,
            signTip1,
            signTip2,
          });
        }
      },
    });
  },
});
